///////////////////////////////////////////////////////////////
// Copyright(c) BeingStudio
// 
// FileName : main
// Creator  : ChenShiCai
// E-Mail   : BeingStudio@GMail.com
// Date     : 2008-05-28
// Comment  : 
//
///////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ProgrammingPearls-02-01.h"


int main(int argc, char* argv[])
{
    int nRetCode = false;

    CHANGE_POS_WORD WordMap;

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcdeaabbccdd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("abcd", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("bcad", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcba", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbfsafsfa", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcbasddddddda", WordMap);
    PROCESS_ERROR(nRetCode);

    nRetCode =  AddWord("dcsadsaba", WordMap);
    PROCESS_ERROR(nRetCode);


    for (CHANGE_POS_WORD::iterator i = WordMap.begin(); i !=  WordMap.end(); i++)
    {
        WORD_LIST *pList = &(i->second); 
        for (WORD_LIST::iterator j = pList->begin(); j !=  pList->end(); j++)
        {
            printf("%s\t", *j);
        }

        printf("\n");

    }
Exit0:
    return 0;
}


